﻿using System;

namespace _07.SelectionSortArray
{
    class SelectionSortArray
    {
        static void Main()
        {
            int[] array = { 9, 8, 5,3,0,7,5};
            int min;
            Console.WriteLine("The array we want to sort is:");
            for (int i = 0; i < array.Length; i++)
            {
                Console.Write(array[i]+" "); 
            }
            for (int i = 0; i < array.Length; i++)
            {
                min = i;
                for (int j = i+1; j < array.Length; j++)
                {
                    if (array[min]>array[j])
                    {
                        min = j;
                    }
                }
                if (min != i)
                {
                    int exchange = array[i];
                    array[i] = array[min];
                    array[min] = exchange;
                }           
            }
            Console.WriteLine("The sorted array is:");
            for (int i = 0; i < array.Length; i++)
            {
                Console.Write(array[i]+" ");
            }
        }
    }
}
